import requests
from bs4 import BeautifulSoup


if __name__ == "__main__":
    server = 'https://www.biqukan8.cc/'
    # target = 'http://www.biqukan8.cc/1_1094/5403177.html'
    target = 'https://www.biqukan8.cc/1_1094/'
    # headers = {
    #     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
    # }
    headers = {
    'authority': 'developer.mozilla.org',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'max-age=0',
    'if-modified-since': 'Mon, 01 Jan 2024 01:39:55 GMT',
    'if-none-match': 'W/"918634a4ef0ed92c43fa7a08593e3df5"',
    'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'document',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
    }
    req = requests.get(url=target,headers=headers)
    html = req.text
    div_bf = BeautifulSoup(html, features="lxml")
    div = div_bf.find_all('div', class_='listmain')
    a_bf = BeautifulSoup(str(div[0]), features="lxml")
    a = a_bf.find_all('a')
    i = 0
    for _ in a:
        print(_.string, server+_.get('href'))
        i+=1
        if i == 10:
            break
